home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / exec.swg / 0014_Execution in a DOS Window.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-01-27  |  3.9 KB  |  129 lines

  1. (*
  2.    Written by Tom Carroll, Nova 24, 1993 for TP 7.0.
  3.  
  4.    Adapted from the example code posted by Kelly Small in the FidoNet
  5.    Pascal echo 11/19/93.
  6.  
  7.    Released to the Public Domain 11/24/93.
  8.  
  9.    Please give credit where credit is due
  10.  
  11.    This Program will execute a program within a text window
  12.    and all program scrolling will be maintained within
  13.    the window.
  14.  
  15.    This would be better to put inside a unit, but I couldn't get the
  16.    interrupt to work within the unit.  If you're able to get it to work
  17.    inside a unit, I would appreciate you posting the unit so I can see
  18.    how it was done.
  19. *)
  20.  
  21. Program ExecInATextWindow;
  22.  
  23. USES
  24.    Dos,  { Used for the Exec call }
  25.    Crt;  { For the GotoXY calls }
  26.  
  27. VAR
  28.    ExitVal    : WORD;
  29.    MyProg     : STRING;
  30.    MyParams   : STRING;
  31.    OldIntVect : POINTER;
  32.  
  33. {$F+}
  34. PROCEDURE Int29Handler(AX, BX, CX, DX, SI, DI, DS, ES, BP : WORD);
  35.  
  36. INTERRUPT;
  37.  
  38. VAR
  39.    Dummy : BYTE;
  40.  
  41. BEGIN
  42.    Write(Chr(Lo(AX)));   { Writes each output character to the screen }
  43.    Asm Sti; END;
  44. END;
  45. {$F-}
  46.  
  47. PROCEDURE HookInt29;
  48.  
  49. BEGIN
  50.    GetIntVec($29, OldIntVect);      { Save the old vector }
  51.    SetIntVec($29, @Int29Handler);   { Install interrupt handler }
  52. END;
  53.  
  54. FUNCTION ExecWin(ProgName, Params : STRING; LeftCol, TopLine,
  55.                  RightCol, BottomLine : WORD) : WORD;
  56.  
  57. VAR
  58.    A : WORD;
  59.  
  60. BEGIN
  61.    GotoXY(LeftCol, TopLine);               { Puts cursor at the top left }
  62.    Write(Chr(201));                        { hand corner of the window   }
  63.  
  64. { I use three FOR loops to write the actual window borders to the screen.
  65.  
  66.   NOTE: The window size for the executed program will actually be two
  67.         rows and two columns smaller that what you call.  This is because
  68.         there is no error checking to see if the call will place the
  69.         window borders outside the maximum row column range for the
  70.         video.                                                           }
  71.  
  72.    FOR A := 1 TO (RightCol-LeftCol) - 1 DO
  73.       Write(Chr(205));
  74.    Write(Chr(187));
  75.    FOR A := 1 TO (BottomLine-TopLine) - 1 DO
  76.       BEGIN
  77.          GotoXY(LeftCol, TopLine + A);
  78.          Write(Chr(186));
  79.          GotoXY(RightCol,TopLine + A);
  80.          Write(Chr(186));
  81.       END;
  82.    GotoXY(LeftCol, BottomLine);
  83.    Write(Chr(200));
  84.    FOR A := 1 TO (RightCol-LeftCol) - 1 DO
  85.       Write(Chr(205));
  86.    Write(Chr(188));
  87.  
  88. { Now set the text window so the program will not scroll the outline of
  89.   the window off the screen.                                            }
  90.  
  91.    Window(LeftCol + 1, TopLine + 1, RightCol - 1, BottomLine - 1);
  92.    GotoXY(1, 1);     { Jumps to the upper left hand corner of the window }
  93.    HookInt29;        { Hooks Interrupt 29 for video output }
  94.    {$M 10000, 0, 0}  { This works good for Archive utilities }
  95.    SwapVectors;
  96.    Exec(ProgName, Params);
  97.    ExecWin := DOSExitCode; { Return the exit code for error trapping }
  98.    SwapVectors;
  99.    SetIntVec($29,OldIntVect); { Restore the interrupt }
  100.    Window(LeftCol, TopLine, RightCol, BottomLine); { Set the window to the }
  101.    ClrScr;                                         { actual size of the    }
  102.    Window(1, 1, 80, 25);                           { border so it can be   }
  103. END;                                               { cleared properly.     }
  104.  
  105. BEGIN
  106.  
  107. ClrScr;
  108.  
  109. { Modify these two lines to suit your system }
  110.  
  111. MyProg := 'C:\UTIL\PKUNZIP.EXE';
  112. MyParams := '-t C:\QMPRO\DL\STORE\WAV\SEINWAV1.ZIP';
  113.  
  114. ExitVal := ExecWin(MyProg, MyParams, 5, 6, 75, 16);
  115.  
  116. WriteLn('DOS exit code = ', ExitVal);
  117.  
  118. ReadLn;
  119.  
  120. END.
  121.  
  122. { I would like to modify this code to allow for a screen save feature that
  123.   will restore the previous screen for the coordinates passed to the ExecWin
  124.   function.
  125.   Other nice features would be to add a sideways scrolling effect,
  126.   exploding windows for the text window and then make it implode when
  127.   the previous video is restored. }
  128.  
  129.